/*
 * Copyright (C) 2009 Leandro Aparecido <lehphyro@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.metalframework.samples.petclinic;

import java.util.*;

import javax.persistence.*;

@Entity
@NamedQuery(name = Veterinarian.ALL, query = "SELECT v FROM Veterinarian v")
public class Veterinarian extends Person {
	
	private static final long serialVersionUID = 7168003578113623230L;

	public static final String ALL = "Veterinarian.all";

	private Set<Specialty> specialties;
	
	public Veterinarian() {
		this(null, null);
	}
	
	public Veterinarian(String firstName, String lastName, Specialty... specialties) {
		super(firstName, lastName);
		
		this.specialties = new HashSet<Specialty>();
		this.specialties.addAll(Arrays.asList(specialties));
	}
	
	@org.hibernate.annotations.CollectionOfElements(targetElement = Specialty.class)
	@Enumerated(EnumType.STRING)
	public Set<Specialty> getSpecialties() {
		return Collections.unmodifiableSet(specialties);
	}
	
	public void setSpecialties(Set<Specialty> specialties) {
		this.specialties = specialties;
	}
	
	public static enum Specialty {
		DENTISTRY {
			@Override
			public String toString() {
				return "dentistry";
			}
		},
		SURGERY {
			@Override
			public String toString() {
				return "surgery";
			}
		},
		RADIOLOGY {
			@Override
			public String toString() {
				return "radiology";
			}
		}
	}
}
